package com.ruoyi.network.utils;

import cn.hutool.core.net.NetUtil;
import com.ruoyi.network.domain.entity.IpAddress;
import com.ruoyi.network.model.vo.IpAddressRequestVO;
import lombok.NoArgsConstructor;

import static lombok.AccessLevel.PRIVATE;

/**
 * @author Administrator
 */
@NoArgsConstructor(access = PRIVATE)
public class IpAddressUtil {


    /**
     * IpAddressRequestVO 数据转换
     *
     * @param vo 网段参数
     */
    public static IpAddress convertIpAddress(IpAddressRequestVO vo) {
        IpAddress ipAddress = new IpAddress();
        ipAddress.setMacAddress(vo.getMacAddress());
        ipAddress.setHostname(vo.getHostname());
        ipAddress.setIpValue(NetUtil.ipv4ToLong(vo.getIpValue()));
        ipAddress.setUsageUserId(vo.getUsageUserId());
        ipAddress.setUsageStatus(vo.getUsageStatus());
        ipAddress.setExpiryStatus(vo.getExpiryStatus());
        ipAddress.setUsageBizId(vo.getUsageBizId());
        ipAddress.setRangeId(vo.getRangeId());
        return ipAddress;
    }
}
